<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<%@ include file="/WEB-INF/views/shared/taglib.jsp"%>
<t:form commandName="weekLog" id="weekLogSimpleAdd" action="/admin/studentManager/weekLog/simpleAdd" ajaxPost="true"  cssClass="form-horizontal" onSuccess="onSuccess">
	<t:panel cssClass="panel-flat border-top-xlg border-top-primary custom-panel" customBody="true" customHead="true">
		<div class="panel-body">
			<t:formgroup>
				<t:label path="projectId" cssClass="col-sm-1" />
				<t:select2 path="projectId" colClass="col-sm-2" />
				<t:label path="teacherId" cssClass="col-sm-1" />
				<t:select2 path="teacherId" placeholder="选择老师" allowClear="true" colClass="col-sm-2" />
				<t:label path="employeeId" cssClass="col-sm-1" />
				<t:select2 path="employeeId" placeholder="选择学生" allowClear="true" colClass="col-sm-2" />
				<t:label path="startDate" cssClass="col-sm-1" />
				<t:date path="startDate" data-min="[]" colClass="col-sm-2" />
			</t:formgroup>
			<t:formgroup>
				<t:label path="name" cssClass="col-sm-1" />
				<t:input path="name" placeholder="输入任务名称回车即可快速添加" colClass="col-sm-8" />
			</t:formgroup>
		</div>
	</t:panel>
</t:form>
<script type="text/javascript">
$(function(){
	$("#weekLogSimpleAdd #name").on("keydown",function(e){
		if(e.which==13){
			e.preventDefault();
			nameEnter();
		}
	});
});
function nameEnter(){
	if($.isNull($("#weekLogSimpleAdd #projectId").val())||$.isNull($("#weekLogSimpleAdd #employeeId").val())){
		$.topNotify("项目和责任人都不能为空");
		return;
	}
	if($.isNull($.trim($("#weekLogSimpleAdd #name").val()))){
		$.topNotify("请输入你要做的事情！");
		return;
	}
	var $simpleAddForm=$("#weekLogSimpleAdd");
	var formData=$simpleAddForm.serialize();
	var action=$simpleAddForm.attr("action");
	var method=$simpleAddForm.attr("method");
	$.ajax({
		url:action,
		data:formData,
		type:method,
		dataType:'json',
		success:function(result){
			if(result.resultType=="success"){
				formSubmit();
				$("#weekLogSimpleAdd #name").val("");
			}
		}
	})
}
</script>